package com.infore.operation.Intercepor;


import com.infore.operation.utils.HttpUtil;
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;


public class LoginInterceptor extends HandlerInterceptorAdapter {
	@Override
	public boolean preHandle( HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
//		String user = request.getHeader("userName");
//		String userId = request.getHeader("userId");
//		String token = request.getHeader("token");
//		if(request.getRequestURI().contains("login")){
//			return true;
//		}
//		Element e = ehcache.get(userId);
//		if (e!=null&&token.equals(e.getObjectValue())) {
//		HttpSession obj =  request.getSession();
//		System.out.println(new Gson().toJson(request.getCookies()));
		System.out.println(request.getRequestURL());
		String uri = request.getRequestURI();
		System.out.println("uri:    "+uri);
//		uri = uri.substring(uri.lastIndexOf("/"), uri.lastIndexOf("."));
//		System.out.println(uri);
		System.out.println(HttpUtil.getVisitorIp(request));
		return true;
//		}
//		return false;
	}

}
	